/*
 * Copyright (C) 2023 Realtek Semiconductor Corp.
 * All Rights Reserved.
 *
 * This program is the proprietary software of Realtek Semiconductor
 * Corporation and/or its licensors, and only be used, duplicated,
 * modified or distributed under the authorized license from Realtek.
 *
 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
 *
 * Purpose :
 *
 * Feature : The file includes the following modules and sub-modules
 *           (1)
 */

#include "app_basic.h"
#include "feature_export_api.h"
#include "omci_driver.h"

static signed customOpt = -1;

unsigned int force_pptp_SpeedDuplexStatus_to_ability_for_link_down(va_list argp)
{
    MIB_TABLE_ETHUNI_T  *pMibPptpEthUni;

	pMibPptpEthUni = va_arg(argp, MIB_TABLE_ETHUNI_T *);
    va_end(argp);

    if(pMibPptpEthUni->OpState != OMCI_ME_ATTR_OP_STATE_DISABLED)
        return FAL_OK;       

    OMCI_LOG(OMCI_LOG_LEVEL_INFO, "%s() OpState=%d SensedType=%d", __FUNCTION__, pMibPptpEthUni->OpState, pMibPptpEthUni->SensedType);

    switch(pMibPptpEthUni->SensedType)
    {
        case OMCI_PLUGIN_UNIT_TYPE_10_100BASE_T:
            pMibPptpEthUni->DuplexInd = PPTP_ETH_UNI_AUTO_DETECT_CFG_100M_FULL_DUPLEX;
            break;
        case OMCI_PLUGIN_UNIT_TYPE_10_100_1000BASE_T:
            pMibPptpEthUni->DuplexInd = PPTP_ETH_UNI_AUTO_DETECT_CFG_1000M_FULL_DUPLEX;
            break;
        default:
            break;
    }
 
	return FAL_OK;
}



unsigned int feature_module_opt_init(unsigned int moduleID, ... )
{
	FAL_ERROR_CODE	ret;    
    va_list argPtr;

    va_start(argPtr, moduleID);
    customOpt = va_arg(argPtr, signed);
    va_end (argPtr);

    ret = feature_api_register(
            FEATURE_API_ME_02000000, moduleID, &force_pptp_SpeedDuplexStatus_to_ability_for_link_down);
    if (FAL_OK != ret)
    {
        printf("%s: Failed to register %u, moduleId %u\n", __FUNCTION__, FEATURE_API_ME_02000000, moduleID);
        return FAL_FAIL;
    }

    return FAL_OK;
}

unsigned int feature_module_exit(void)
{
	feature_api_unregister(FEATURE_API_ME_02000000);
    return FAL_OK;
}

